<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Admin_daily_report_detail_model extends CI_Model {

	public function __construct()
	{
		parent::__construct();
		$this->load->database();
	}

	//get all companies
	public function get_all($cond)
	{
		$query = $this->db->select('dt.id, dt.earn_name, dt.earn_value, dt.spend_name, dt.spend_value');
				$this->db->from('admin_daily_report_details dt');
				$this->db->join('admin_daily_reports dlp', 'dt.id = dlp.id', 'left');
				$this->db->where($cond);
				$query = $this->db->get();

		return $query->result();
	}

	//insert
	public function add_new($data) {
		if($this->db->insert('admin_daily_report_details', $data)) {

			$this->db->where($data);
			$res = $this->db->get('admin_daily_report_details')->result();
			
			return $res[0]->id;
		}else 
			return -1; //insert fail
	}	

	//edit
	public function edit($data, $cond) {
		$this->db->where($cond);
		if($this->db->update('admin_daily_report_details', $data))
			return true;
		return false;
	}

	//delete
	public function delete($cond) {
		if($this->db->delete('admin_daily_report_details', $cond)) 
			return true;
		return false;
	}

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */